<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('厂家信息档案列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>厂家名称：</label>
                                <input type="text" name="factoryName"/>
                            </li>
                            <li>
                                <label style="width: 100px;">厂家负责人：</label>
                                <input type="text" name="factoryPerson"/>
                            </li>
                            <li>
                                <label style="width: 120px;">负责人手机号：</label>
                                <input type="text" name="factoryPhone"/>
                            </li>
                            <li>
                                <label style="width: 120px;">厂家详细地址：</label>
                                <input type="text" name="factoryDetailAddress"/>
                            </li>
                            <li>
                                <label style="width: 120px;">厂家微信昵称：</label>
                                <input type="text" name="factoryNickname"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="factoryState" th:with="type=${@dict.getType('zsyh_review')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">是否显示电话：</label>
                                <select name="isShowPhone" th:with="type=${@dict.getType('zsyh_yesno')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="zsyh:factory:add">
                    <i class="fa fa-plus"></i> 添加新厂家
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:factory:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:factory:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>-->
               <!-- <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:factory:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:factory:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:factory:remove')}]];
        var factoryStateDatas = [[${@dict.getType('zsyh_review')}]];
        var isShowPhoneDatas = [[${@dict.getType('zsyh_yesno')}]];
        var prefix = ctx + "zsyh/factory";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "厂家信息档案",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '厂家信息Id',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'factoryName',
                    align: 'center',
                    title: '厂家名称'
                },{
                    field: 'factoryNameVirtual',
                    align: 'center',
                    title: '虚拟厂家名称'
                },
                {
                    field: 'factoryPerson',
                    align: 'center',
                    title: '厂家负责人'
                },
                {
                    field: 'factoryPhone',
                    align: 'center',
                    title: '负责人手机号'
                },{
                    field: 'factoryPhoneVirtual',
                    align: 'center',
                    title: '虚拟手机号'
                },
                {
                    field: 'factoryDetailAddress',
                    align: 'center',
                    title: '厂家详细地址'
                },
                {
                    field: 'factoryEmail',
                    align: 'center',
                    title: '邮箱地址'
                },
                /*{
                    field: 'factoryImages',
                    title: '厂家头像',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'factoryNickname',
                    title: '厂家微信昵称'
                },*/
                {
                    field: 'factoryLicence',
                    align: 'center',
                    title: '营业执照',
                    formatter: function (value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'factoryBalance',
                    align: 'center',
                    title: '厂家账户余额'
                },
                {
                    field: 'factoryMoney',
                    align: 'center',
                    title: '厂家账户保证金'
                },
                    {
                        field: 'factoryState',
                        align: 'center',
                        title: '状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(factoryStateDatas, value);
                        }
                    },
                    {
                        field: 'isShowPhone',
                        align: 'center',
                        title: '是否显示电话',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(isShowPhoneDatas, value);
                        }
                    },
                {
                    title: '操作',
                    align: 'center',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<div style="display: flex">');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a style="margin-left: 3px;" class="btn btn-info btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="viewFactory(\'' + row.id + '\')"><i class="fa fa-bell-o"></i>查看详情</a>');
                        actions.push('<a style="background-color: #ff191f;color: white;margin-left: 3px;" class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="resetPassword(\'' + row.id + '\')"><i class="fa fa-key"></i>重置密码</a>');
                        actions.push('</div>');
                        actions.push('<div style="display: flex;margin-top: 6px;">');
                        actions.push('<a style="background-color: #ff9219;color: white;margin-left: 3px;" class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="addBalance(\'' + row.id + '\')"><i class="fa fa-gift"></i>余额充值</a>');
                        actions.push('<a style="background-color: #007d76;color: white;margin-left: 3px;" class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="addMoney(\'' + row.id + '\')"><i class="fa fa-get-pocket"></i>质保金充值</a>');
                        actions.push('<a style="background-color: #287dc1;color: white;margin-left: 3px;" class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="viewAccount(\'' + row.id + '\')"><i class="fa fa-get-pocket"></i>查看账户变动</a>');
                        if(row.factoryState == '0'){
                            actions.push('<a style="background-color: #a27bc1;color: white;margin-left: 3px;" class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="reviewFactory(\'' + row.id + '\')"><i class="fa fa-lock"></i>审核</a>');
                        }
                        actions.push('</div>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function viewFactory(id) {
            var url = prefix+"/viewFactory/"+id;
            $.modal.openTab("查看详情", url);
        }

        function addBalance(id) {
            $.modal.open('余额充值', prefix + "/addBalance/"+id, '500', '200');
        }

        function addMoney(id) {
            $.modal.open('质保金充值', prefix + "/addMoney/"+id, '500', '200');
        }

        function reviewFactory(id) {
            var url = prefix + "/reviewFactory/"+id;
            layer.open({
                type: 2,
                area: ['500px', '350px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "平台审核",
                content: url,
                closeBtn: 1,
                /*btn: ['通过', '驳回'],*/
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    debugger;
                    var iframeWin = layero.find('iframe')[0];
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

        function viewAccount(id) {
            $.modal.open('查看账户变动', prefix + "/viewAccount/"+id, '1000', '500');
        }

        function resetPassword(id) {
            var url = prefix + '/resetPwd/' + id;
            $.modal.open("重置密码", url, '800', '300');
        }

    </script>
</body>
</html>